package cn.sh.yhk.base.vo;

import lombok.Data;

import java.io.Serializable;

/**
 * @Classname Yhk
 * @Description TODO
 * @Version 1.0.0
 * @Date 2024/9/6 15:58
 * @Created by y6522
 */
@Data
public class BaseResponse<T> implements Serializable {

    private int code;

    private T data;

    private String message;

    public BaseResponse(int code, T data, String message) {
        this.message = message;
        this.data = data;
        this.code = code;
    }

    public static <T> BaseResponse<T> success() {
        return new BaseResponse<>(200, null, "success");
    }


    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(200, data, "success");
    }


    public static <T> BaseResponse<T> success(String msg) {
        return new BaseResponse<>(200, null, msg);
    }

    public static <T> BaseResponse<T> fail(T data) {
        return new BaseResponse<>(400, data, "fail");
    }

    public static <T> BaseResponse<T> fail(String errMsg) {
        return new BaseResponse<>(400, null, errMsg);
    }

    public static <T> BaseResponse<T> err(String errMsg) {
        return new BaseResponse<>(500, null, errMsg);
    }


}


